package com.huqs.smoothphotoview.library.progress;

import android.util.Log;
import android.view.View;

import com.bumptech.glide.request.target.Target;
import com.huqs.smoothphotoview.library.view.RoundNumProgressView;

/**
 * Created by huqs on 2017/4/24.
 */

public class LoaderProgressTarget<Z> extends ProgressTarget<String, Z>  {
    private final RoundNumProgressView mProgressView;
    private final String TAG_LOG="log";
    public LoaderProgressTarget(Target<Z> target,RoundNumProgressView progressView) {
        super(target);
        mProgressView=progressView;
    }
    //下载进度加载更新时间
    @Override
    public float getGranularityPercentage() {
        return 0.1f;
    }
    //正在连接网络
    @Override
    protected void onConnecting() {
        mProgressView.setVisibility(View.VISIBLE);
    }
    //正在下载图片
    @Override
    protected void onDownloading(long bytesRead, long expectedLength) {
        int progress= (int) (100*bytesRead / expectedLength) ;
        mProgressView.setCurProgress(progress);
    }
    //图片下载完成，正在转码和转换
    @Override
    protected void onDownloaded() {
    }
    //图片显示
    @Override
    protected void onDelivered() {
        mProgressView.setVisibility(View.GONE);
    }
}
